Skip to content

Conversation

@samwyndham
Copy link
Contributor

@samwyndham samwyndham commented Oct 31, 2025

TaskWPB-19688 [iOS] Move DB data model to `WireData`

Issue

This PR is a new version of #3521. As that PR was quite far behind develop and the core data model has changed, I decided to combine changes from the original PR with a few updates.

This PR moves the zmessaging and ZMEventModel database models from WireDataModel framework to WireData package ensuring that the managed objects that were previously pointing to the Current Product Module now points to WireDataModel (where still reside their related subclasses).

To achieve this:

  • Model files were moved to WireData
  • Managed object subclass files were left in WireDataModel - these can be moved one by one as needed.
  • The module for each entity was changed to WireDataModelis previously it was set asCurrent Product Module` - see notes below.
  • The locations of the model bundles were updated in tests.
  • In Xcode project based modules that depend on core data, their test hosts were updated to link to the modules target. E.g. WireRequestStrategyTestHost was updated to link to WireRequestStrategy. Without doing this the WireDataBundle.bundle would crash trying to find the bundle. This change ensures that the compiled core data module resides in the test host and is therefore accessible in tests. This was the main difference to the original PR: chore: move db models to wire data package - WPB-19688 #3521
  • A new test host was added for WireDomain to address the above issue as it was missing a test host.

This PR is largely @jullianms good work - my changes mainly relate to resolving test host issue

Some additional notes

Some things I've learnt which I didn't know before regarding the classes module:

Screenshot 2025-08-25 at 10 24 12

This can have 3 states:

  • Global Namespace
  • Current Product Module
  • Custom (we enter a target)

Global Namespace is required for managed object subclasses that are obj-c or those that are used from obj-c. This is because obj-c uses a global namespace (hence the need to add prefixes).

Current Product Module is like Custom but automatically sets the target based on where the database models reside. Currently Current Product Module resolves to WireDataModel but with this PR we move the database models to WireData while keeping the classes in WireDataModel. This means that we have to updates settings of Current Product Module to WireDataModel.

I was surprised at the need to update each version of zmessaging.xcdatamodeld, not just 2.129 but 2.128, 2.127, etc. This was necessary because some of our migration tests depend on our managed object subclasses with older database versions. For example, DatabaseMigrationTests_Conversations.testThatItPerformsMigrationFrom106_deleteConversationCascadesToParticipantRole(). I think this is a little problematic as there is no reason why the current version of ParticipantRole is compatible with version 2.106.0 for example. It would be better to use just NSManagedObject with KVC. However it's probably best to leave things how they are.

Testing

  • Ensure app is building and running properly
  • Ensure all unit tests are passing test run here
  • Ensure database migration from 2.130 to 2.131 is working properly

Checklist

  • Title contains a reference JIRA issue number like [WPB-XXX].
  • Description is filled and free of optional paragraphs.
  • Adds/updates automated tests.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2025

Test Results

    7 files    654 suites   7m 48s ⏱️
5 362 tests 5 361 ✅ 0 💤 1 ❌
5 363 runs  5 363 ✅ 0 💤 0 ❌

For more details on these failures, see this check.

Results for commit 669dfc7.

♻️ This comment has been updated with latest results.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Oct 31, 2025

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 669dfc7 | Docs | Was this helpful? Give us feedback!

Copy link
Collaborator

@netbe netbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left a few comments, but otherwise looks good to me :)

Question: Can we close #3521 ?

@samwyndham samwyndham added this pull request to the merge queue Nov 5, 2025
Merged via the queue into develop with commit 3a6deb7 Nov 5, 2025
25 of 26 checks passed
@samwyndham samwyndham deleted the chore/move-core-data branch November 5, 2025 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants